<template>
  <div id="app">
    <div class="header">我是header</div>
    <div class="middle">
        <div class="left">
              <div @click="shopManager" :class="this.$store.state.index==1 ? 'sidebar2':'sidebar'   ">
                  商品管理
              </div>
             <div @click="userManager"  :class="this.$store.state.index==2 ? 'sidebar2':'sidebar'   ">
                  用户管理
              </div>
              <div @click="staffManager" :class="this.$store.state.index==3 ? 'sidebar2':'sidebar'   ">
                  员工管理
              </div>
        </div>
         <div class="right">
             <router-view></router-view>
        </div>
    </div>

    <div class="footer">我是footer</div>
  </div>
</template>


<script>
export default {
  name: "App",
  props: [],
  components: {},
  data() {
    return {};
  },
  //方法 函数写这里
  methods: {
    shopManager(){
      this.$store.commit('shopManager',1)
      this.$router.push('/shop')
    },
    userManager(){
       this.$store.commit('userManager',2)
    },
     staffManager(){
       this.$store.commit('staffManger',3)
    }
  },
  //计算属性
  computed: {},
  //侦听器
  watch: {},
  //过滤器
  filters: {},
  //以下是生命周期
  //组件创建之前
  beforeCreate() {},
  //组件创建之后
  created() {},
  //页面渲染之前
  beforeMount() {},
  //页面渲染之后
  mounted() {},
  //页面视图数据更新之前
  beforeUpdate() {},
  //页面视图数据更新之后
  updated() {},
  //页面销毁之前
  beforeDestroy() {},
  //页面销毁之后
  destroyed() {},
};
</script>
<style lang="scss">

.header {
  width: 100%;
  height: 5vh;
  background-color: #2a5caa;
  color: white;
  text-align: center;
  line-height: 5vh;
}

.footer {
  width: 100%;
  height: 5vh;
  position: absolute;
  left: 0;
  bottom: 0;
  color: white;
  text-align: center;
  line-height: 5vh;
  background-color: skyblue;
}



.middle {
   display: flex; 
   width: 100%;
    height: 90vh;
     min-height: 90vh;
}

.left {
 width: 180px;
 height: 100%;
 background-color: slateblue;
}

.right {
  flex: 1;
  height: 100%;
  background-color: springgreen;
}



.sidebar2 {
  height: 30px; 
  margin-top: 10px; 
  background-color: black;
  color: white;
  cursor: pointer;
  line-height: 30px;
}


.sidebar {
    height: 30px; 
  margin-top: 10px; 
  background-color: skyblue;
  color: white;
  cursor: pointer;
  line-height: 30px;
}
 
 


</style>
